<?php

namespace App\View\Components;

use App\Models\Admin;
use App\Models\FilmTypeMaster;
use App\Models\Warranty;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\View\Component;

class DealerSelect extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(Request $request)
    {
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {

        $items = $this->items();

        return view('components.dealer-select', [
            'items' => $items,
        ]);
    }

    public function items()
    {

        $did = session('admin.id');
        $data = Admin::where('status', 1)
            ->where('creator_id', $did)
            ->orderBy('status')
            ->orderByRaw(DB::raw('FIELD(mdtype, 1,3,4,2)'))
            ->orderBy('unique_id')
            ->select(['id', 'abbr'])
            ->get();
        return $data;
    }
}
